package lines.gameengine;

import static java.lang.String.format;

/**
 * Value class which represent a point of field.
 * @author vpotapenko
 */
public final class FieldPoint {

    private static final String TO_STRING_PATTERN = "(%d, %d)";

    /** Horizontal coordinate of the point */
    private final int x;

    /** Vertical coordinate of the point */
    private final int y;

    public FieldPoint(int x, int y) {
        this.x = x;
        this.y = y;
    }

    /**
     * Returns horizontal coordinate of the point
     * @return horizontal coordinate of the point
     */
    public int getX() {
        return x;
    }

    /**
     * Returns vertical coordinates of the point
     * @return vertical coordinates of the point
     */
    public int getY() {
        return y;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null || obj.getClass() != FieldPoint.class) return false;

        FieldPoint another = (FieldPoint) obj;
        return another.x == x && another.y == y;
    }

    @Override
    public String toString() {
        return format(TO_STRING_PATTERN, x, y);
    }
}
